package com.wuxuehua.myapp.repository;

import com.wuxuehua.myapp.domain.Shop;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import org.springframework.data.jpa.repository.*;
import java.util.List;

/**
 * Spring Data JPA repository for the Shop entity.
 */
@SuppressWarnings("unused")
@Repository
public interface ShopRepository extends JpaRepository<Shop, Long> {

    @Query("select shop from Shop shop where shop.user.login = ?#{principal.username}")
    Page<Shop> findByUserIsCurrentUser(Pageable pageable);

    @Query("select shop from Shop shop where shop.user.login = ?#{principal.username} and shop.start <> 0")
    Page<Shop> findByUserIsCurrentUserAndStartNot0(Pageable pageable);

    List<Shop> findAllByUser_Id(Long userId, Pageable pageable);



}
